More Related Content
Similar to computer notes - Data Structures - 13
Similar to computer notes - Data Structures - 13 (20)
More from ecomputernotes (19)
computer notes - Data Structures - 13
- 1. Class No.13 Data Structures http://ecomputernotes.com
- 2. Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p p->setRight( node ); node http://ecomputernotes.com
- 12. Traversing a Binary Tree void preorder(TreeNode<int>* treeNode) { if( treeNode != NULL ) { cout << *(treeNode->getInfo())<<" "; preorder(treeNode->getLeft()); preorder(treeNode->getRight()); } } http://ecomputernotes.com
- 13. Traversing a Binary Tree void inorder(TreeNode<int>* treeNode) { if( treeNode != NULL ) { inorder(treeNode->getLeft()); cout << *(treeNode->getInfo())<<" "; inorder(treeNode->getRight()); } } http://ecomputernotes.com
- 14. Traversing a Binary Tree void postorder(TreeNode<int>* treeNode) { if( treeNode != NULL ) { postorder(treeNode->getLeft()); postorder(treeNode->getRight()); cout << *(treeNode->getInfo())<<" "; } } http://ecomputernotes.com
- 15. Traversing a Binary Tree cout << "inorder: "; preorder( root); cout << "inorder: "; inorder( root ); cout << "postorder: "; postorder( root ); http://ecomputernotes.com
- 16. Traversing a Binary Tree Preorder: 14 4 3 9 7 5 15 18 16 17 20 14 15 4 9 7 18 3 5 16 20 17 http://ecomputernotes.com
- 17. Traversing a Binary Tree Inorder: 3 4 5 7 9 14 15 16 17 18 20 14 15 4 9 7 18 3 5 16 20 17 http://ecomputernotes.com
- 18. Traversing a Binary Tree Postorder: 3 5 7 9 4 17 16 20 18 15 14 14 15 4 9 7 18 3 5 16 20 17 http://ecomputernotes.com
Editor's Notes
- End of lecture 12
- End of lecture 13.